fix(node-api): unbounded filter input#3102
Open
bar-bera wants to merge 3 commits into
Open
Conversation
### Cause
Unbounded input in API request
* `POST /eth/v1/beacon/states/{state_id}/validators`
* `POST /eth/v1/beacon/states/{state_id}/validator_balances`
### Issue
O(N*M) algorithmic complexity DoS with
* N validator registry (not set) size
* M attacker slice size (indices or pubkeys)
### Impact
With Berachain reduced validator set (N_registry ~= 100) lower impact than stated.
Server work per request at N=100:
* Numeric path, M=100k: ~10⁷ uint64 compares ≈ ~10 ms CPU.
* Pubkey path, M=100k: ~10⁷ × 48-byte memcmp ≈ ~100–500 ms CPU.
Impact is worse for `validator_balances` (state read).
### Likelyhood
Unauth request. Cost in bandwidth:
| Field type | Per-entry bytes (JSON) | M=10^5 body | M=10^6 body |
|---|---|---|---|
| Numeric ID `"12345"` | ~7–9 | ~800 KB | ~8 MB |
| Hex pubkey `"0x"` + 96 hex | ~102 | ~10 MB | ~100 MB |
### Fix
* Cap on inputs
* Filter implementation by mapping instead of arrays.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR mitigates an algorithmic-complexity DoS vector in the beacon node API validator-filtering endpoints by bounding filter input sizes and reducing per-validator filter-matching work.
Changes:
- Reworked validator ID/pubkey matching from linear
slices.Containschecks to O(1) map lookups. - Added request validation caps for IDs/statuses on
/validatorsand IDs on/validator_balances. - Added constants for the caps and a test covering the
/validatorsID cap.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
node-api/handlers/beacon/validators_filters.go |
Switches validator filter membership checks from slices to maps to avoid O(N*M) behavior. |
node-api/handlers/beacon/validators_filters_test.go |
Adds a test asserting requests over the max IDs cap are rejected. |
node-api/handlers/beacon/types/request.go |
Enforces per-request caps via struct-tag validation on validator IDs/statuses. |
node-api/handlers/beacon/types/limits.go |
Introduces named constants for request caps. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3102 +/- ##
==========================================
+ Coverage 61.21% 61.24% +0.03%
==========================================
Files 369 369
Lines 18925 18927 +2
==========================================
+ Hits 11584 11592 +8
+ Misses 6382 6378 -4
+ Partials 959 957 -2
🚀 New features to boost your workflow:
|
fridrik01
reviewed
May 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Unbounded input in API request
POST /eth/v1/beacon/states/{state_id}/validatorsPOST /eth/v1/beacon/states/{state_id}/validator_balancescauses O(N*M) algorithmic complexity DoS with
With Berachain registry size < 100 impact is minimal.
Fix